'''
登录 -> 得到cookie
带着cookie 去请求到书架url -> 书架上的内容

必须得把上面的两个操作连起来
我们可以使用session 进行请求 -> session 可以认为是一连串的请求, 在这个过程中的cookie 不会丢失
'''
import requests

# 会话
session = requests.session()
# 登录信息
data = {
    "loginName": "15836365301",
    "password": "Nps15836365301"
}

head = {
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36"
}

# 可以使用session 登录的方式
# 登录
url = "http://www.hao123.com/resource/page/v3Jump.html"
session.post(url, data=data, headers=head)
# 获取书架数据
resp = session.get("https://user.17k.com/ck/author2/shelf?page=1&appKey=2406394919")



# 无法登录的另一种方式  headers 中输入cookie 值
# 用户登录后 使用requests 获取
resp = requests.get("https://user.17k.com/ck/author2/shelf?page=1&appKey=2406394919", headers= {
    "cookie": "GUID=e541a19d-49fa-457d-90a4-e48e0933ec81; sajssdk_2015_cross_new_user=1; c_channel=0; c_csc=web; Hm_lvt_9793f42b498361373512340937deb2a0=1739089783; HMACCOUNT=D5AADBCDD937117E; acw_sc__v2=67a874e261149eb7c9eb487b9c3f1de1f16094e8; BAIDU_SSP_lcr=http://www.hao123.com/book; tfstk=gSaoaGTzPuo5fnw9e-u5fLFu83IxFQgIcJLKp2HF0xkjp_M-eWy3t5oEaUy8mv24nYuKyzQ3xxurAuHKev03ORfABNQTN7gIzOBOWTd07V3saeuepmRq_2czmwKNy7gI8tdv8GQgNRWy2U4r8s0q9bvr8eyE0jkjOXJrTU50gxMqTU8rUx-qObYeaJuFiSkjT2lrwtIrFyz4utAInoraPYzmZ0DaiGtexeGXBvVrne8EEbnkm7kD8ez0D64I8YS6Mvg-F7ludNTSzDqUyqzP3wuaf-4nbVjdN0P3mJg8u6-rQue-vziDU3lirYmazmQGgqiUmr08z9t_MSDrjqEAcTnKr8qsC0SfhJVmeJzo0LXxplFYzm2NHE2Ixkz-uzWVSg7H0h-64eGV9rxBA0ljiApaCccw7miJysfDb6irGbMOisxBA0ljiACcihSS4jGSB; Hm_lpvt_9793f42b498361373512340937deb2a0=1739093269; ssxmod_itna=QqUxgQIx07DtdGHDODUjfuYYKbf=Qx7wqD=dDc0r0x0yI3GzDAxn40iDtPaH4r674fWA8=CD5WqecRhAbXWRCRK56FC=4bDHxY=DUP3+wYD435GwD0eG+DD4DWDmnHDnxAQDjxGPyn2v5CDYPDEBKDaxDbDimkAxGCDeKD0=THDQKDugIYqjiCdDDzdiS4q0IxDYmhd9cwy1O1qjBKkBKD9poDsh+UstgUZUisdtk6e948DlIRDCFzygyHHFrCVE5hWDcepeheTiFrkQiaKCRb1HpqLk0Y/mn4a6G5muhy9XDDi6hYyXhDD=; ssxmod_itna2=QqUxgQIx07DtdGHDODUjfuYYKbf=Qx7wqD=dDc0rDnKMioSeDskkQDLj6iGqdNqidAlgkh0=T0ck02GTS=RyIOqC7DvYCtbjxcjPBz+1+x0+vj2yGuxctG80zqv3jjBtKPtG70=XwqKl7REoWRNcGTY50dr8mqXxfuXInEe1CDpx7xG2t4GcDijPeD==; accessToken=avatarUrl%3Dhttps%253A%252F%252Fcdn.static.17k.com%252Fuser%252Favatar%252F19%252F59%252F49%252F103994959.jpg-88x88%253Fv%253D1739089856000%26id%3D103994959%26nickname%3Dnumnum_%26e%3D1754646050%26s%3Dbd9dc03eec4ef30e; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%22103994959%22%2C%22%24device_id%22%3A%22194e9a048d517c-0eeed64dc1f046-26011951-1327104-194e9a048d657d%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E5%BC%95%E8%8D%90%E6%B5%81%E9%87%8F%22%2C%22%24latest_referrer%22%3A%22http%3A%2F%2Fwww.hao123.com%2Fbook%22%2C%22%24latest_referrer_host%22%3A%22www.hao123.com%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC%22%7D%2C%22first_id%22%3A%22e541a19d-49fa-457d-90a4-e48e0933ec81%22%7D"
})


